package xj.graph2d.command;

import xj.graph2d.SimpleDrawDocument;
import xj.graph2d.SimpleDrawView;
import xj.graph2d.shapes.CurveShape;

public class MoveCurveCommand extends DeltaCommand {

  public static final int CURVE_END_1 = 101;

  public static final int CURVE_END_2 = 102;

  public static final int CURVE_CTR_1 = 201;

  public static final int CURVE_CTR_2 = 202;

  public MoveCurveCommand(SimpleDrawView view, SimpleDrawDocument doc,
			  CurveShape shape, int pos) {
    super(view, doc, shape);
    this.pos = pos;
  }

  @Override
  protected void forward() {
    CurveShape cs = (CurveShape) shape;
    switch (pos) {
    case CURVE_END_1:
      cs.moveEnd1Adj(x, y);
      break;
    case CURVE_END_2:
      cs.moveEnd2Adj(x, y);
      break;
    case CURVE_CTR_1:
      cs.moveCtr1(x, y);
      break;
    case CURVE_CTR_2:
      cs.moveCtr2(x, y);
      break;
    }
  }

  @Override
  protected void backward() {
    CurveShape cs = (CurveShape) shape;
    switch (pos) {
    case CURVE_END_1:
      cs.moveEnd1Adj(-x, -y);
      break;
    case CURVE_END_2:
      cs.moveEnd2Adj(-x, -y);
      break;
    case CURVE_CTR_1:
      cs.moveCtr1(-x, -y);
      break;
    case CURVE_CTR_2:
      cs.moveCtr2(-x, -y);
      break;
    }
  }

  protected int pos;

}
